<?php


namespace app\admin\controller;


use think\Controller;

class About extends Allow
{
    public function index()
    {
        $about = db("copy_descr")->select();
//        dump($about);die;
        $this->assign([
            'about' => $about,
            'total' => count($about)
        ]);
        return view("index");

    }
    public function edit()
    {
        $id = (int)input("id");
        $data = db("copy_descr")->find($id);
        $this->assign([
            'data' => $data
        ]);
        return view("edit");
    }
    public function executeData()
    {
        $id = input("id");
        $data = request()->except("id");
        $copy_descr = db("copy_descr")->where("id",$id)->find();
        $data['img'] = editImage($data,$copy_descr,'img');
        $res = db("copy_descr")->where("id",$id)->update($data);
        if(!$res) return ['code' => -1,'msg' => '修改失败'];
        return ['code' => 200,'msg' => '修改成功'];
    }
}